package cn.pattern.demo5;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 代理类要做的事情
 * @auth wzy
 * @date 2023/10/10 16:28
 */
public class IntermedirayInvocationHandler implements InvocationHandler {

    // 目标对象
    private Object target;

    public Object getTarget() {
        return target;
    }

    public void setTarget(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("ProxyBuyer看房前。。。");
        // 核心事情
        Object result = method.invoke(target, args);

        System.out.println("ProxyBuyer看房后。。。");
        return result;
    }

}
